package com.ygnn.config;

import com.ygnn.common.interceptor.JwtTokenUserInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName:WebMvcConfiguration
 * Package:com.ygnn.config
 * Description:
 *
 * @Author: dlh
 * @Creat:2024/10/28-22:20
 */
@Configuration
@Slf4j
public class WebMvcConfiguration implements WebMvcConfigurer {
    @Autowired
    private JwtTokenUserInterceptor jwtTokenUserInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("开始注册自定义拦截器...");
        registry.addInterceptor(jwtTokenUserInterceptor)
                .addPathPatterns("/order/**") // 需要拦截的路径
                .excludePathPatterns("/index.html", "/show.html", "/AllData.html") // 排除静态资源
                .excludePathPatterns("/static/**"); // 排除静态资源目录
    }
}
